<template>
    <div class="finance-dashboard">
        <!-- 顶部导航栏 -->
        <div class="top-nav">
            <div class="nav-left">
                <span class="logo">22.com</span>
            </div>
            <div class="nav-right">
                <span class="date">{{ currentDate }}</span>
            </div>
        </div>
        <!-- 主要内容区域 -->
        <div class="main-content">
            <!-- 趋势图表区域 -->
            <div class="chart-section">
                <SmoothedLine/>
            </div>
            <div class="strategy-section">
                <StrategyStatistics/>
            </div>
            <!-- 多股票趋势比较图表 -->
            <div class="multi-chart-section">
                <MultipleXAxes/>
            </div>
        </div>
        <BottomNav/>
    </div>
</template>

<script>
import {ref, onMounted} from 'vue'
import BottomNav from '../components/BottomNav.vue'
import SmoothedLine from '../components/index/smoothedLine.vue'
import StrategyStatistics from '../components/index/strategyStatistics.vue'
import MultipleXAxes from '../components/index/multipleXAxes.vue'

export default {
    name: 'MyView',
    components: {
        BottomNav,
        MultipleXAxes,
        StrategyStatistics,
        SmoothedLine
    },
    setup() {
        // 这里可以添加响应式数据和方法
        const activeRange = ref('7天')
        const currentDate = ref('')

        // 格式化当前日期
        const formatCurrentDate = () => {
            const now = new Date()
            const year = now.getFullYear()
            const month = String(now.getMonth() + 1).padStart(2, '0')
            const day = String(now.getDate()).padStart(2, '0')
            const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
            const weekday = weekdays[now.getDay()]

            currentDate.value = `今天是${year}年${month}月${day}日 ${weekday}`
        }

        // 组件挂载时设置日期
        onMounted(() => {
            formatCurrentDate()
        })

        const handleRangeChange = (range) => {
            activeRange.value = range
            // 这里可以添加切换时间范围的逻辑
        }

        return {
            activeRange,
            handleRangeChange,
            currentDate
        }
    }
}
</script>

<style scoped>
.finance-dashboard {
    min-height: 100vh;
    background-color: #f5f7fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 顶部导航栏 */
.top-nav {
    background-color: #fff;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #ff3b30;
}

.date {
    font-size: 14px;
    color: #666;
}

/* 主要内容区域 */
.main-content {
    padding: 24px;
    max-width: 1440px;
    margin: 0 auto;
}

/* 趋势图表区域 */
.chart-section {
    background-color: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}


/* 持股策略说明 */
.strategy-section {
    background-color: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 多股票趋势比较图表 */
.multi-chart-section {
    background-color: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 90px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@keyframes drawChart {
    0% {
        width: 0;
    }
    100% {
        width: 100%;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        padding: 0px;
    }

    /* 顶部导航栏 */
    .top-nav {
        padding: 0 16px;
        height: 50px;
    }

    .logo {
        font-size: 20px;
    }

    .date {
        font-size: 12px;
    }

    /* 图表区域 */
    .chart-section {
        padding: 0px;
        margin-bottom: 16px;
    }

    /* 时间范围选择器 */
    .time-range {
        gap: 8px;
    }

    .range-btn {
        padding: 6px 16px;
        font-size: 13px;
        border-radius: 16px;
    }


    /* 多图表区域 */
    .multi-chart-section {
        padding: 0px;
        margin-bottom: 16px;
    }

    .multi-chart-container {
        height: 250px;
    }

    /* 图表图例 */
    .chart-legend {
        flex-wrap: wrap;
        gap: 12px;
    }

    .legend-item {
        gap: 6px;
    }

    .legend-text {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .strategy-section {
        background-color: #fff;
        border-radius: 12px;
        padding: 14px;
    }
    .chart-section {
        padding: 0px;
        margin-bottom: 16px;
        /* 添加边框并隐藏 */
        border: 1px solid transparent;
    }
    .multi-chart-section {
        padding: 0px;
        margin-bottom: 16px;
        /* 添加边框并隐藏 */
        border: 1px solid transparent;
    }
    /* 进一步缩小尺寸 */
    .main-content {
        padding: 0px;
    }

    .total-assets {
        font-size: 28px;
    }

    .chart-container,
    .multi-chart-container {
        height: 200px;
    }

    .range-btn {
        padding: 5px 12px;
        font-size: 12px;
    }

    .card-name {
        font-size: 14px;
    }

    .card-value {
        font-size: 18px;
    }

    .chart-legend {
        gap: 8px;
    }
}
</style>
